/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.sBean;

import com.aptech.entities.TblProject;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Winner
 */
@Stateless
public class TblProjectFacade extends AbstractFacade<TblProject> {

    @PersistenceContext(unitName = "Elevation_System_Online-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public TblProjectFacade() {
        super(TblProject.class);
    }

    public List<TblProject> getProjectByManagerID(int mnID) {
        Query query = em.createNamedQuery("TblProject.findByManager");
        query.setParameter("mnID", mnID);
        return query.getResultList();
    }

    public List<TblProject> getProjectByStatus1() {
        Query query = em.createNamedQuery("TblProject.findByPrState1");
        return query.getResultList();
    }

    public List<TblProject> getProjectByStatus2() {
        Query query = em.createNamedQuery("TblProject.findByPrState2");
        return query.getResultList();
    }

    public List<TblProject> getTblProjectByOdID(int odID) {
        Query query = em.createNamedQuery("TblProject.findByOdID");
        query.setParameter("odID", odID);
        return query.getResultList();
    }
    public List<TblProject> getTblProjectByDateCreated(Date dateStart,Date dateEnd) {
        Query query = em.createNamedQuery("TblProject.findByDatePrCreated");
        query.setParameter("dateStart", dateStart);
        query.setParameter("dateEnd", dateEnd);
        return query.getResultList();  
    }
    public List<TblProject> getTblProjectByDateCompleted(Date dateStart,Date dateEnd) {
        Query query = em.createNamedQuery("TblProject.findByDatePrCompleted");
        query.setParameter("dateStart", dateStart);
        query.setParameter("dateEnd", dateEnd);
        return query.getResultList();  
    }
}
